package test4;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class TestPool {
    public static void main(String[] args) {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1,3,
                20, TimeUnit.SECONDS,new ArrayBlockingQueue<>(3));
        for (int i = 0; i < 7; i++) {
            threadPoolExecutor. submit(()->{
                System.out.println(Thread.currentThread().getName()+"is working...");
            });
        }

        threadPoolExecutor.shutdown();
    }
}
